package test.my.com.myapplicationtest.comment_textview;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import test.my.com.myapplicationtest.R;

/**
 * Created by ThinkPad on 2016/2/22.
 */
public class CommentActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aty_comment_layout);
        LinearLayout ll = (LinearLayout) findViewById(R.id.ll);
        Comment comment = new Comment("隔壁老王","大头儿子是我亲生的~~~");
        CommentTextView comment_tv = new CommentTextView(this);
        comment_tv.addComment(comment.name, comment.content, comment, new CommentTextView.OnNameClickListener<Comment>() {
            @Override
            public void clickCommentName(Comment comment) {
                Toast.makeText(CommentActivity.this,comment.content,Toast.LENGTH_SHORT).show();
            }

            @Override
            public void clickReplyName(Comment comment) {

            }
        });
        ll.addView(comment_tv);

        Comment comment2 = new Comment("隔壁隔壁老王","老王！你这个畜生~~~");
        CommentTextView comment_tv2 = new CommentTextView(this);
        comment_tv2.addReply("小头小头小头爸爸",comment2.name, comment2.content, comment2, new CommentTextView.OnNameClickListener<Comment>() {
            @Override
            public void clickCommentName(Comment comment) {
                Toast.makeText(CommentActivity.this,"哈哈",Toast.LENGTH_SHORT).show();
            }

            @Override
            public void clickReplyName(Comment comment) {
                Toast.makeText(CommentActivity.this,comment.name+comment.content,Toast.LENGTH_SHORT).show();
            }
        });
        ll.addView(comment_tv2);
    }

    class Comment{
        String name;
        String content;

        public Comment(String name, String content) {
            this.name = name;
            this.content = content;
        }
    }
}
